#ifndef __DX11_RLDO_H__
#define __DX11_RLDO_H__

#include <d3d11.h>
#include <assert.h>

// Add `D3D11_CREATE_DEVICE_DEBUG` to the `Flags` parameter of `D3D11CreateDevice` function call.
/*
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
*/

// call this function just before releasing `ID3D11Device*` interface.
inline void ReportLiveDeviceObjects(ID3D11Device* g_pd3dDevice)
{
#ifdef _DEBUG
    ID3D11Debug* DebugDevice = nullptr;
    HRESULT hr = S_OK;
    hr = g_pd3dDevice->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&DebugDevice));
    if (SUCCEEDED(hr))
    {
        hr = DebugDevice->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);
        assert(SUCCEEDED(hr));
        DebugDevice->Release();
    }
#endif
}

#endif // !__DX11_RLDO_H__
